package com.mk.service.platform;

import act.controller.Controller;
import com.github.d925529.apidoc.ApiHttpMethod;
import com.github.d925529.apidoc.annotation.*;
import com.mk.domain.TArea;
import com.mk.interceptor.ITranslate;
import com.mk.util.S2;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.annotation.PostAction;
import org.osgl.mvc.annotation.PutAction;
import org.osgl.mvc.annotation.With;

import javax.inject.Inject;
import javax.validation.constraints.NotNull;

/**
 * 说明：区域后台服务
 * 作者：292303959@qq.com 
 * 日期：2018-10-17 10:4:53 
 * 版本：1.0.0
 */
@Controller("tArea")
@Api(group = "pl",title = "区域服务", path = "/tArea")
@SuppressWarnings("unused")
public class TAreaService extends BasePlatformService {
    @Inject
    private TArea.Mapper tAreaMapper;


    @With({ILogin.class, ITranslate.class})
    @PostAction("add.json")
    @ApiMethod(title = "增加保存区域", path = "/add.json", method = ApiHttpMethod.POST)
    @ApiParam(name = "tArea", title = "区域", type = TArea.class)
    @ApiReturn(description = "主键", type = String.class)
    public String add(@NotNull TArea tArea) {
        String id = S2.UUID();
        tArea.setAreacode(id);
        tAreaMapper.insertTemplate(tArea);
        return id;
    }


    @With({ILogin.class, ITranslate.class})
    @PutAction("update.json")
    @ApiMethod(title = "修改保存区域", path = "/update.json", method = ApiHttpMethod.PUT)
    @ApiParam(name = "tArea", title = "区域", type = TArea.class)
    @ApiReturn(description = "修改了的数量", type = int.class)
    public int update(@NotNull TArea tArea) {
        return tAreaMapper.updateTemplateById(tArea);
    }

    @With(ILogin.class)
    @GetAction("view.json")
    @ApiMethod(title = "查询指定区域", path = "/view.json", method = ApiHttpMethod.GET)
    @ApiParam(name = "id", title = "区域的主键", type = String.class)
    @ApiReturn(description = "区域", type = TArea.class)
    public TArea view(@NotNull String id){
        return tAreaMapper.single(id);
    }
}
